2023-07-10
Using .desktop Files for Bookmarks
Trying to use bookmarks in browsers to go to commonly visited sites is unfortunately a somewhat terrible experience. So long ago I switched to just doing that externally: Until now I just used a script that opened all these bookmarks in a menu (fuzzel, but any dmenu-like menu works for stuff like this). But as a fan of "do what I mean" features, it always annoyed me how this was yet another separate menu; Press Super+d
for applications and Super+o
for bookmarks. A bit primitive.
Having custom actions appear in application menus on linux is actually trivial. Just write a custom .desktop
file and put it into ~/.local/share/applications/
. Each bookmark in its own desktop file would be a bit excessive, but luckily the spec allows to have more than one action per .desktop
file.
Here is an example:
[Desktop Entry]
Encoding=UTF-8
Name=bookmark
Comment=online bookmarks
Exec=firefox
Terminal=false
Type=Application
Icon=firefox
Actions=my-site;sourcehut;
[Desktop Action my-site]
Name=My Website
Exec=firefox https://leon_plickat.srht.site
[Desktop Action sourcehut]
Name=sourcehut
Exec=firefox "https://git.sr.ht/"
Now I can open sourcehut inside firefox comfortably from my application menu. No longer do I first have to waste a thought on whether the thing I want to open is an application or a website (and honestly some things are simply both). Nice.

This obviously also works with local files. There are a few books I use often, so I created entries for them as well, this time using xdg-open
as the opener.

Having to edit .desktop
files to add bookmarks is not very convenient. However the ability to open commonly used webpages and files from my application launcher is worth it for me. I know the launchers of the big desktops do something similar out of the box, but mine doesn't and this is a fine workaround in the meantime. Also I was never particularly happy with how both gnomes launcher and krunner find important files anyway, so at least for me the actual UX of my .desktop
file is a tiny bit better, since it gives me direct control over what does appear in the menu and what doesn't.
I do eventually want to have an application launcher menu that allows me to insert non-application entries programmatically, but for now this is enough.